/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * userPreferencesPanel.java
 *
 * Created on 18/05/2011, 20:14:04
 */

package presentation;

/**
 *
 * @author Andreu Marimon
 */
public class ProgramPreferencesPanel extends javax.swing.JPanel {
    PresentationController _pCntrl;
    /** Creates new form userPreferencesPanel */
    private String _color = "BLUE";
    private int _size = 14;
    private boolean _assistent= true;


    private void getUserInfo(){
	_color = _pCntrl.getTextColor();
	_size = _pCntrl.getTextSize();
	if(_pCntrl.getAssistant()==1) _assistent = true;
	else _assistent = false;
    }
    public ProgramPreferencesPanel(PresentationController pCntrl) {
        _pCntrl = pCntrl;
	initComponents();
	getUserInfo();
	sizeSlider.setValue(_size);
	int index = 0;
	if (_color.equals("BLUE")) index = 0;
	if (_color.equals("GREEN")) index = 1;
	if (_color.equals("ORANGE")) index = 2;
	if (_color.equals("RED")) index = 3;
	colorComboBox.setSelectedIndex(index);
	assistentCheckBox.setSelected(_assistent);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        okButton = new defaultJButton();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        sizeSlider = new javax.swing.JSlider();
        colorComboBox = new javax.swing.JComboBox();
        assistentCheckBox = new javax.swing.JCheckBox();

        setMaximumSize(new java.awt.Dimension(252, 403));
        setMinimumSize(new java.awt.Dimension(252, 403));
        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(252, 403));

        okButton.setText("Ok");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("verb color");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
        jLabel3.setText("font size");

        sizeSlider.setMaximum(30);
        sizeSlider.setMinimum(8);

        colorComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Blue", "Green", "Orange", "Red" }));
        colorComboBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                colorComboBoxActionPerformed(evt);
            }
        });

        assistentCheckBox.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        assistentCheckBox.setText("show assistent");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(sizeSlider, javax.swing.GroupLayout.Alignment.LEADING, 0, 0, Short.MAX_VALUE)
                    .addComponent(okButton, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(assistentCheckBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(colorComboBox, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(89, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(jLabel3)
                .addGap(3, 3, 3)
                .addComponent(sizeSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(colorComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(assistentCheckBox)
                .addGap(18, 18, 18)
                .addComponent(okButton)
                .addContainerGap(191, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
	int index = colorComboBox.getSelectedIndex();
	if (index == 0) _pCntrl.setTextColor("BLUE");
	else if(index == 1) _pCntrl.setTextColor("GREEN");
	else if (index == 2) _pCntrl.setTextColor("ORANGE");
	else _pCntrl.setTextColor("RED");
	_pCntrl.setTextSize(sizeSlider.getValue());
	if (assistentCheckBox.isSelected()) {
		_pCntrl.setAssistant(1);
		//System.out.println("assistent");
	}
	else {
		//System.out.println("no assistent");
		_pCntrl.setAssistant(0);
	}
    }//GEN-LAST:event_okButtonActionPerformed

    private void colorComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_colorComboBoxActionPerformed
	// TODO add your handling code here:
    }//GEN-LAST:event_colorComboBoxActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox assistentCheckBox;
    private javax.swing.JComboBox colorComboBox;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JButton okButton;
    private javax.swing.JSlider sizeSlider;
    // End of variables declaration//GEN-END:variables

}
